# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=gdnsd
pkgver=3.8.0
pkgrel=0
pkgdesc="Geographic Authoritative DNS server"
url="https://github.com/gdnsd/gdnsd/"
arch="all"
license="GPL-3.0-or-later"
makedepends="
	autoconf
	automake
	libcap-dev
	libev-dev
	libmaxminddb-dev
	libsodium-dev
	libtool
	ragel
	userspace-rcu-dev
	"
checkdepends="
	perl
	perl-libwww
	perl-socket6
	perl-io-socket-inet6
	perl-http-daemon
	perl-test-harness
	perl-test-harness-utils
	"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://github.com/gdnsd/gdnsd/releases/download/v$pkgver/gdnsd-$pkgver.tar.xz
	dclists.patch
	gdnsd.initd"
options="!check" # missing perl modules for tests

[ "$CARCH" = "riscv64" ] && options="$options textrels"

# secfixes:
#   2.4.3-r0:
#     - CVE-2019-13952

prepare() {
	default_prepare
	autoreconf -vif
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--enable-fast-install
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm755 "$srcdir"/gdnsd.initd "$pkgdir"/etc/init.d/gdnsd
}

sha512sums="
165c5576b1142a873dcd54b42f1b58a3ecd1958b274eb5e3c09fbd918b5851f554213605b062dea966cc7502d6e91ec79e32c121aba23ea4e560db6b488106af  gdnsd-3.8.0.tar.xz
ad1519c076e0f8b55ce9e202790cf64b1ab81f10b1c770fcd050acc96ad7d99a0be1bd7bd0791de3d920e1a85993131f9638934567792a060b8dfe52f7e00bea  dclists.patch
7e66f9d3dab3a36334d47740f12ee7f3ffd363d416bd1fcca4b339db8ba858419555751786247ffc4e5faf68c6b5fa87b84c04ffa25133a17b186bdf83c365b9  gdnsd.initd
"
